<template>
  <!-- 使用 -->
  <!-- 1. 文件放在 svg目录下 -->
  <!-- 2. <v-icon name="文件名"/> -->
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName" :fill="color"/>
  </svg>
</template>

<script>
export default defineComponent({
  props: {
    name: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ''
    },
    color: {
      type: String,
      default: ''
    },
  },
  setup(props) {
    return {
      iconName: computed(() => `#icon-${props.name}`),
      svgClass: computed(() => {
        if (props.className) {
          return `${props.className}`
        }
        return ''
      })
    }
  }
})
</script>

<style>

</style>
